home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1998 May / Macworld (1998-05).dmg / Updaters / SoftWindows 95 5.0.2 / SoftWindows Upgrade Disk / SoftWindows Upgrade Disk / SWUPDATE.BAT < prev    next >
DOS Batch File  |  1998-02-17  |  14KB  |  389 lines

  1. @echo off
  2. @if not "%8" == "" echo %8
  3. rem [
  4. rem    Name:        u.swupdate.bat
  5. rem
  6. rem    Derived from:    (original)
  7. rem
  8. rem    Author:        David Lillie
  9. rem
  10. rem    Created on:    Sep 1996
  11. rem
  12. rem    Sccs ID:    @(#)u.swupdate.bat    1.50 10/13/97
  13. rem
  14. rem    Coding Stds:    
  15. rem
  16. rem    Purpose:    To upgrade a SoftWindows hard disk container file.
  17. rem            This is called automatically.
  18. rem
  19. rem    Parameters:    1    host OS type i.e. "mac" or "unix"
  20. rem            2    new serial number (8 hex digits)
  21. rem            3    old serial number (8 hex digits)
  22. rem            4    Host System name
  23. rem            5    Host System release
  24. rem            6    Host System version
  25. rem            7    Host System hardware type
  26. rem            8    On/Off argument for echo
  27. rem            9    Drive letter for "WIN95" setup directory.
  28. rem
  29. rem    Copyright 1997 Insignia Solutions PLC. All rights reserved.
  30. rem ]
  31.  
  32.  
  33. rem Set path to upgrade utils (for an automatic upgrade)
  34. if exist d:\insignia\ibatch.exe path d:\;d:\insignia;%path%
  35.  
  36. rem Check to see if we have a valid first parameter
  37. if "%1"=="" goto manstamp
  38. rem Set up host OS environment variable
  39. ibatch swupdate_host tolower %1
  40. if "%swupdate_host%"=="unix" goto CheckSerial
  41. if "%swupdate_host%"=="mac" goto CheckSerial
  42. goto manstamp
  43.  
  44. :CheckSerial
  45. rem Check that we have the right number of parameters
  46. if "%9"=="" goto manstamp
  47.  
  48.  
  49. rem  Make copy of serial number which we might modify
  50. set new_sn=%2
  51.  
  52. rem Get language code from serial number.
  53. ibatch langNO string "%new_sn%" 2 2
  54. ibatch langNO tolower "%langNO%"
  55.  
  56. rem Determine which language extension to use
  57. call dec_lang langID %langNO%
  58. if not "%langID%" == "" goto GotLang
  59.  
  60. rem  Unknown language in requested serial number.
  61. rem  Try to detect the language from the hard disk.
  62. call findlang langNO
  63.  
  64. rem  Insert the language code into the serial number
  65. ibatch sn_head string "%new_sn%" 0 2
  66. ibatch sn_tail string "%new_sn%" 4 4
  67. set new_sn=%sn_head%%langNO%%sn_tail%
  68. set sn_head=
  69. set sn_tail=
  70.  
  71. call dec_lang langID %langNO%
  72. if not "%langID%" == "" goto GotLang
  73.  
  74. echo Unrecognised language on drive C:
  75. pause
  76. goto reboot
  77.  
  78. :GotLang
  79.  
  80. rem  Ensure we have 'our' directory.
  81. if not exist c:\insignia\nul md c:\insignia
  82.  
  83. rem  If there is no upgrade history, extract what we can from
  84. rem  the last upgrade log (if there was one).
  85. rem  We are interested in the two top batch files and the serial numbers of
  86. rem  the disks (searching for "-" finds the serial nos independent of language).
  87. if exist c:\insignia\uphist.log goto nonewhist
  88. if not exist c:\insignia\up.log goto nonewhist
  89. find /i /n "swupdate" c:\insignia\up.log >> c:\insignia\uphist.log
  90. find /i /n "w95once"  c:\insignia\up.log >> c:\insignia\uphist.log
  91. find /i /n "-"        c:\insignia\up.log >> c:\insignia\uphist.log
  92. :nonewhist
  93.  
  94. rem  Create log file afresh for each upgrade. Append to the history file.
  95. echo %0 %1 %2 %3 %4 %5 %6 %7 %8 %9    > c:\insignia\up.log
  96. echo. | date                >>c:\insignia\up.log
  97. echo. | time                >>c:\insignia\up.log
  98. vol c:                    >>c:\insignia\up.log
  99. vol d:                    >>c:\insignia\up.log
  100. echo %0 %1 %2 %3 %4 %5 %6 %7 %8 %9    >>c:\insignia\uphist.log
  101. echo. | date                >>c:\insignia\uphist.log
  102. echo. | time                >>c:\insignia\uphist.log
  103. vol c:                    >>c:\insignia\uphist.log
  104. vol d:                    >>c:\insignia\uphist.log
  105.  
  106. rem  Get interesting part of old serial number in lower case.
  107. ibatch old_swinv string %3 0 2
  108. ibatch old_swinv tolower %old_swinv%
  109.  
  110.  
  111. if not "%swupdate_host%" == "unix" goto no_esave
  112.  
  113. rem    Load FSA drivers and save user's E: drive setup. We need to restore
  114. rem    it because "net use" changes the user's configuration.
  115. rem     We need to frig the DOS version for devlod on Windows 95 disks.
  116.  
  117. dosver 6 0  d:\insignia\devlod.com d:\insignia\host.sys >>c:\insignia\up.log
  118. fsadrive >>c:\insignia\up.log
  119. net use e: | ibatch swupdate_edir string 0 0
  120.  
  121. rem    Obtain selected keyboard defaults file if any.
  122. rem    We do this here because we need to re-use FSA drive E: later.
  123. rem    (Having bypassed config.sys, the effective LASTDRIVE is E:)
  124.  
  125. net use e: /d>>c:\insignia\up.log
  126. net use e: $SWINHOME/local>>c:\insignia\up.log
  127. copy d:\unixonly\keybdef.unx c:\insignia\keyboard.def                >>c:\insignia\up.log
  128. if exist e:\selected\keyboard.def copy e:\selected\keyboard.def c:\insignia    >>c:\insignia\up.log
  129. net use e: /d>>c:\insignia\up.log
  130.  
  131. :no_esave
  132.  
  133. rem Ensure that critical files are writable (we make some read-only)
  134. if exist c:\insignia\*.*        attrib -r c:\insignia\*.* /s
  135. if exist c:\windows\pif\suspend.pif    attrib -r c:\windows\pif\suspend.pif
  136.  
  137. rem  Copy this file to drive C for manual updates.
  138. copy d:\swupdate.bat c:\insignia        >>c:\insignia\up.log
  139.  
  140. if not exist c:\windows\system.ini goto dosonly
  141. rem Test for Windows 95
  142. if exist c:\windows\ios.ini goto rawwin95
  143. rem Test for Windows For Workgroups
  144. if exist c:\windows\clipsrv.exe goto rawwfw
  145. rem Test for Windows 3.11 (NB emm386.exe exists on G:\ and C:\windows in
  146. rem a split setup).
  147. if exist c:\windows\emm386.exe goto rawwin311
  148.  
  149. :dosonly
  150. set swupdate_os=dos
  151. set space_needed=5000
  152. checkspc %space_needed%
  153. if not errorlevel 1 goto no_space
  154.  
  155. echo Adding Insignia drivers to MS-DOS on drive C: ...
  156.  
  157. rem Remove obsolete stuff
  158. call delfiles list c:\windows c:\windows\system %swupdate_os% %1
  159.  
  160. rem Copy files.
  161. xcopy /y d:\insignia        c:\insignia    >>c:\insignia\up.log
  162. xcopy /y d:\%1only        c:\insignia    >>c:\insignia\up.log
  163. if not exist c:\nwclient\nul md    c:\nwclient    >>c:\insignia\up.log
  164. xcopy /s /y d:\nwclient        c:\nwclient    >>c:\insignia\up.log
  165. c:
  166. cd \insignia
  167.  
  168. rem Only overwrite config.sys and autoexec.bat if it is a clean (CD2) hard disk
  169. if "%old_swinv%" == "f0" call dosbatch %1 %langID% dos
  170.  
  171. rem call d:\%1.bat dos c:\windows\system %langID% %4 %5 %6 %7
  172. goto purestamp
  173.  
  174. :rawnowin
  175. echo No version of Windows installed on C:
  176. pause
  177. goto reboot
  178.  
  179. :rawwfw
  180. set swupdate_os=wfw311
  181. set swupdate_os_name=Windows for Workgroups 3.11
  182. goto win31_and_wfw
  183.  
  184. :rawwin311
  185. set swupdate_os=win311
  186. set swupdate_os_name=Windows 3.11
  187. :win31_and_wfw
  188.  
  189. if not "%swupdate_host%" == "unix" goto win31hdf
  190.  
  191. rem Detect split setup (the default for Unix Swin 2.0)
  192. rem    If user.exe is present in G:\ and absent from C:\windows\system then
  193. rem    this is a split setup. If it exists in both places then it means that
  194. rem    either win2c.bat has been run, or it was put there ad hoc; either way
  195. rem    it implies a hard disk only setup.
  196. rem    Because we have bypassed config.sys and autoexec.bat, we need to set up
  197. rem    FSA and find the fsa windows directory explicitly. Furthermore we are
  198. rem    constrained to drive E: because we cannot execute a LASTDRIVE command.
  199.  
  200. if exist c:\windows\system\user.exe goto win31hdf
  201. net use e: /d>>c:\insignia\up.log
  202. net use e: $SWINHOME/windows>>c:\insignia\up.log
  203.  
  204. if exist e:\user.exe goto win31fsa
  205. net use e: /d>>c:\insignia\up.log
  206. goto rawnowin
  207.  
  208. :win31hdf
  209. set space_needed=5000
  210. checkspc %space_needed%
  211. if not errorlevel 1 goto no_space
  212. echo Adding Insignia drivers to %swupdate_os_name% on drive C: ...
  213. set swupdate_windir=c:\windows
  214. set swupdate_sysdir=c:\windows\system
  215. goto win31both
  216.  
  217. :win31fsa
  218. set space_needed=4000
  219. checkspc %space_needed%
  220. if not errorlevel 1 goto no_space
  221. echo Adding Insignia drivers to %swupdate_os_name% on FSA drive $SWINHOME/windows ...
  222. set swupdate_windir=e:
  223. set swupdate_sysdir=e:
  224.  
  225. :win31both
  226.  
  227. rem Remove obsolete stuff
  228. call delfiles list %swupdate_windir% %swupdate_sysdir% %swupdate_os% %1
  229.  
  230. rem Copy files.
  231. xcopy /y d:\insignia c:\insignia    >>c:\insignia\up.log
  232. xcopy /y d:\%1only   c:\insignia    >>c:\insignia\up.log
  233.  
  234. call copywinf d:\insignia\for_win    %swupdate_windir%    >>c:\insignia\up.log
  235. call copywinf d:\%1only\for_win        %swupdate_windir%    >>c:\insignia\up.log
  236. call copywinf d:\insignia\for_w31    %swupdate_windir%    >>c:\insignia\up.log
  237. call copywinf d:\%1only\for_w31        %swupdate_windir%    >>c:\insignia\up.log
  238. xcopy /y d:\insignia\for_win\system    %swupdate_sysdir%    >>c:\insignia\up.log
  239. xcopy /y d:\%1only\for_win\system     %swupdate_sysdir%    >>c:\insignia\up.log
  240. xcopy /y d:\insignia\for_w31\system    %swupdate_sysdir%    >>c:\insignia\up.log
  241. xcopy /y d:\%1only\for_w31\system    %swupdate_sysdir%    >>c:\insignia\up.log
  242. if not exist c:\nwclient\nul md        c:\nwclient        >>c:\insignia\up.log
  243. xcopy /s /y d:\nwclient            c:\nwclient        >>c:\insignia\up.log
  244. if exist d:\%langID%only\for_win\nul call copywinf d:\%langID%only\for_win %swupdate_windir% >>c:\insignia\up.log
  245. c:
  246. cd \insignia
  247.  
  248. rem Only overwrite config.sys and autoexec.bat if it is a clean (CD2) hard disk
  249. if "%old_swinv%" == "f0" call dosbatch %1 %langID% win31
  250.  
  251. call w31batch %swupdate_windir% %swupdate_sysdir% %swupdate_os% %1 %langID% %3
  252. call d:\%1.bat win31 %swupdate_sysdir% %langID% %4 %5 %6 %7
  253. if "%swupdate_host%" == "unix" net use e: /d>>c:\insignia\up.log
  254. goto purestamp
  255.  
  256. :rawwin95
  257. ver | find "4." | ibatch swupdate_os_name string 0 10
  258. ibatch swupdate_os string "%swupdate_os_name%" 8 2
  259. set swupdate_os=win%swupdate_os%
  260.  
  261. set space_needed=10000
  262. checkspc %space_needed%
  263. if not errorlevel 1 goto no_space
  264.  
  265. echo Adding Insignia drivers to %swupdate_os_name% ...
  266.  
  267. rem Remove obsolete stuff
  268. call delfiles list c:\windows c:\windows\system %swupdate_os% %1
  269.  
  270. rem Copy files.
  271. xcopy /y d:\insignia        c:\insignia    >>c:\insignia\up.log
  272. xcopy /y d:\%1only        c:\insignia    >>c:\insignia\up.log
  273. xcopy /s /y d:\insignia\for_win    c:\windows    >>c:\insignia\up.log
  274. xcopy /s /y d:\%1only\for_win    c:\windows    >>c:\insignia\up.log
  275. xcopy /s /y d:\insignia\for_w95    c:\windows    >>c:\insignia\up.log
  276. xcopy /s /y d:\%1only\for_w95    c:\windows    >>c:\insignia\up.log
  277. if not exist c:\nwclient\nul md    c:\nwclient    >>c:\insignia\up.log
  278. xcopy /s /y d:\nwclient        c:\nwclient    >>c:\insignia\up.log
  279. if exist d:\%langID%only\for_win\nul xcopy /s /y d:\%langID%only\for_win c:\windows >>c:\insignia\up.log
  280. c:
  281. cd \insignia
  282.  
  283. rem Only overwrite config.sys and autoexec.bat if it is a clean (CD2) hard disk
  284. if "%old_swinv%" == "f0" call dosbatch %1 %langID% win95
  285.  
  286. call w95batch %swupdate_host% %new_sn% %3 %4 %5 %6 %7 %swupdate_os%
  287.  
  288. rem  Construct reg file to add the runonce entry and
  289. rem  repair the installation source path (BCN 5506).
  290. echo REGEDIT4>c:\insignia\runonce.reg
  291.  
  292. echo.>>c:\insignia\runonce.reg
  293. echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce]>>c:\insignia\runonce.reg
  294. echo "IS_Customize"="c:\\insignia\\w95once.bat %swupdate_host% %new_sn% %3 %4 %5 %6 %7 %8 %langID%">>c:\insignia\runonce.reg
  295.  
  296. set W95SourcePath=%9:\\%swupdate_os%
  297. ibatch W95SourcePath toupper "%W95SourcePath%"
  298. if not "%swupdate_host%" == "unix" goto no_unix95
  299. rem  On Unix SoftWindows95, setup files are optionally installed on
  300. rem  $SWINHOME/win95 (or $SWINHOME/win98) which is mounted on G:
  301. net use e: /d>>c:\insignia\up.log
  302. net use e: $SWINHOME>>c:\insignia\up.log
  303. if exist e:\%swupdate_os%\mini.cab set W95SourcePath=G:\\
  304. net use e: /d>>c:\insignia\up.log
  305. :no_unix95
  306. rem  The setup files may still be on disk, in which case we should use them.
  307. if exist c:\windows\options\cabs\mini.cab set W95SourcePath=C:\\WINDOWS\\OPTIONS\\CABS
  308.  
  309. echo.>>c:\insignia\runonce.reg
  310. echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]>>c:\insignia\runonce.reg
  311. echo "SourcePath"="%W95SourcePath%">>c:\insignia\runonce.reg
  312. set W95SourcePath=
  313.  
  314. regedit c:\insignia\runonce.reg            >>c:\insignia\up.log
  315. echo.>>c:\insignia\up.log
  316.  
  317. rem  Set up likely paths for Windows 95 setup files.
  318. mruedit  d:\insignia\mrumod.spt        >>c:\insignia\up.log
  319.  
  320. rem  Early versions of SoftWindows95 1.0 reported the wrong PnP ID for the
  321. rem  Insignia ESDI controller. We patch the correct ID into the registry here,
  322. rem  to prevent Windows displaying a reboot prompt during the upgrade.
  323. set enum_key=HKEY_LOCAL_MACHINE\Enum
  324. set eb_esdi_key=[%enum_key%\BIOS\*ISL060A]
  325. regedit /e c:\insignia\temp.reg %enum_key%    >>c:\insignia\up.log
  326. type c:\insignia\temp.reg | find "%eb_esdi_key%" | ibatch found_key string 0 0
  327. if not "%found_key%" == "%eb_esdi_key%" regedit d:\ins_esdi.reg    >>c:\insignia\up.log
  328. echo.>>c:\insignia\up.log
  329. del c:\insignia\temp.reg    >>c:\insignia\up.log
  330.  
  331. call d:\%1.bat win95 c:\windows\system %langID% %4 %5 %6 %7
  332. goto purestamp
  333.  
  334. :purestamp
  335. echo Update complete.
  336. rem
  337. rem Restore user's FSA drive
  338. if not "%swupdate_edir%" == "" net use %swupdate_edir%>>c:\insignia\up.log
  339. rem
  340. rem Update disk version number
  341. rem
  342. debug <d:\upcode.inp d:\empty %new_sn% >nul
  343. goto reboot
  344.  
  345. :manstamp
  346. rem  swupdate has been activated manually
  347. rem Log the manual upgrade to the history file.
  348. echo Manual upgrade activated. OS=%1, Extra Parameters %2 %3 %4 %5 %6 %7 %8 %9 >>c:\insignia\uphist.log
  349.  
  350. rem
  351. rem Set the first two digits of serial number to F1 and reboot.
  352. rem This will force an upgrade with the correct parameters
  353. debug <c:\insignia\upman.inp >nul
  354. goto reboot
  355.  
  356. :reboot
  357. rem
  358. rem Restore user's FSA drive
  359. if not "%swupdate_edir%" == "" net use %swupdate_edir%>>c:\insignia\up.log
  360. rem
  361. rem Reboot
  362. rem
  363. debug <c:\insignia\reboot.inp >nul
  364. rem We should not get here, but if we do..
  365. goto End
  366.  
  367. :no_space
  368. cls
  369. set sn=%space_needed%
  370. echo **************************************************************************
  371. echo *                                                                        *
  372. echo *                              WARNING                                   *
  373. echo *                                                                        *
  374. echo * There is not enough free space on your C: drive to perform the         *
  375. echo * upgrade.  You need a minimum of %sn%000 bytes free.                    *
  376. echo *                                                                        *
  377. echo * To increase the available free space, either:                          *
  378. echo * delete any unwanted files and restart; or increase the size            *
  379. echo * of your C: drive as described in the product documentation.            *
  380. echo *                                                                        *
  381. echo **************************************************************************
  382. goto End
  383.  
  384. :End
  385. rem
  386. rem Restore user's FSA drive
  387. if not "%swupdate_edir%" == "" net use %swupdate_edir%>>c:\insignia\up.log
  388.  
  389.